<script>
	export default {
		globalData: {  
			open_id: '',
			avatar_url: '',
			nick_name: '',
			phone:'15880949650',
			user_id: 0,
			user_name: '',
			inviter_name: '',
			inviter_id: 0,
			isLogin: false
		},  
		onLaunch: function() {					
		},
		onShow: function() {
			let globalData = this.$scope.globalData
			// 请求腾讯服务器获取code
			uni.login({
			  provider: 'weixin',
			  success: function (loginRes) {	
				let code = loginRes.code;	
				// 请求小程序登陆接口获取用户open_id
				uni.request({
					url: 'https://lianmai.techny.cn/wx/get_open_id?code=' + code,
					method: 'GET',
					data: {					
					},
					header: {						
					},
					success: (res) => {		
						console.log(res)
						if(res.errMsg == 'request:ok'){
							globalData.open_id = JSON.parse(res.data[0]).openid
						}									
					},
					fail: (res)=>{
						uni.showModal({
						    title: '提示',
						    content: '小程序获取用户权限失败, 请重新进入!'
						});						
					}
				});							
			  }
			});	
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	@import './common/uni.css';
	/*每个页面公共css */
	page {
		min-height: 100vh;
		background: #F8F8F8;
	}
	
	.c-main {
		color: #f13b32;
	}
	
	.c-gray {
		color: #bdbdbd;
	}
</style>
